<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Class: Service_</title>

    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Class: Service_</h1>

    




<section>

<header>
    
        <h2><span class="attribs"><span class="type-signature"></span></span>Service_<span class="signature">(serviceName)</span><span class="type-signature"></span></h2>
        
    
</header>

<article>
    <div class="container-overview">
    
        

    

    
    <h4 class="name" id="Service_"><span class="type-signature"></span>new Service_<span class="signature">(serviceName)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    Creates a new OAuth2 service.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>serviceName</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last">The name of the service.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>




















    
    </div>

    

    

    

    

    

    

    

    
        <h3 class="subsection-title">Methods</h3>

        
            

    

    
    <h4 class="name" id="exchangeGrant_"><span class="type-signature"></span>exchangeGrant_<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    Obtain an access token using the custom grant type specified. Most often
this will be "client_credentials", and a client ID and secret are set an
"Authorization: Basic ..." header will be added using those values.
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>




















        
            

    

    
    <h4 class="name" id="fetchToken_"><span class="type-signature"></span>fetchToken_<span class="signature">(payload, optUrl<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Object}</span></h4>
    

    



<div class="description">
    Fetches a new token from the OAuth server.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>payload</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last">The token request payload.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>optUrl</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last">The URL of the token endpoint.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    The parsed token.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Object</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="generateCodeVerifier"><span class="type-signature"></span>generateCodeVerifier<span class="signature">()</span><span class="type-signature"> &rarr; (non-null) {<a href="Service_.html">Service_</a>}</span></h4>
    

    



<div class="description">
    Sets the code verifier to a randomly generated challenge string.
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    This service, for chaining
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Service_.html">Service_</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="getAccessToken"><span class="type-signature"></span>getAccessToken<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4>
    

    



<div class="description">
    Gets an access token for this service. This token can be used in HTTP
requests to the service's endpoint. This method will throw an error if the
user's access was not granted or has expired.
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    An access token.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">string</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="getAuthorizationUrl"><span class="type-signature"></span>getAuthorizationUrl<span class="signature">(optAdditionalParameters)</span><span class="type-signature"> &rarr; {string}</span></h4>
    

    



<div class="description">
    Gets the authorization URL. The first step in getting an OAuth2 token is to
have the user visit this URL and approve the authorization request. The
user will then be redirected back to your application using callback function
name specified, so that the flow may continue.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>optAdditionalParameters</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last">Additional parameters that should be
    stored in the state token and made available in the callback function.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    The authorization URL.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">string</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="getIdToken"><span class="type-signature"></span>getIdToken<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4>
    

    



<div class="description">
    Gets an id token for this service. This token can be used in HTTP
requests to the service's endpoint. This method will throw an error if the
user's access was not granted or has expired.
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    An id token.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">string</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="getLastError"><span class="type-signature"></span>getLastError<span class="signature">()</span><span class="type-signature"> &rarr; {Exception}</span></h4>
    

    



<div class="description">
    Gets the last error that occurred this execution when trying to automatically
refresh or generate an access token.
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    An error, if any.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Exception</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="getRedirectUri"><span class="type-signature"></span>getRedirectUri<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4>
    

    



<div class="description">
    Returns the redirect URI that will be used for this service. Often this URI
needs to be entered into a configuration screen of your OAuth provider.
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    The redirect URI.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">string</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="getStorage"><span class="type-signature"></span>getStorage<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="Storage_.html">Storage_</a>}</span></h4>
    

    



<div class="description">
    Gets the storage layer for this service, used to persist tokens.
Custom values associated with the service can be stored here as well.
The key <code>null</code> is used to to store the token and should not
be used.
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    The service's storage.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Storage_.html">Storage_</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="getToken"><span class="type-signature"></span>getToken<span class="signature">(optSkipMemoryCheck<span class="signature-attributes">nullable</span>)</span><span class="type-signature"> &rarr; {Object}</span></h4>
    

    



<div class="description">
    Gets the token from the service's property store or cache.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>optSkipMemoryCheck</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>

            
                <td class="attributes">
                

                
                    &lt;nullable><br>
                

                
                </td>
            

            

            <td class="description last">If true, bypass the local memory cache
    when fetching the token.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    The token, or null if no token was found.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Object</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="handleCallback"><span class="type-signature"></span>handleCallback<span class="signature">(callbackRequest)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
    

    



<div class="description">
    Completes the OAuth2 flow using the request data passed in to the callback
function.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>callbackRequest</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last">The request data recieved from the callback
    function.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    True if authorization was granted, false if it was denied.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">boolean</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="hasAccess"><span class="type-signature"></span>hasAccess<span class="signature">()</span><span class="type-signature"> &rarr; {boolean}</span></h4>
    

    



<div class="description">
    Determines if the service has access (has been authorized and hasn't
expired). If offline access was granted and the previous token has expired
this method attempts to generate a new token.
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    true if the user has access to the service, false
    otherwise.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">boolean</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="refresh"><span class="type-signature"></span>refresh<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    Refreshes a token that has expired. This is only possible if offline access
was requested when the token was authorized.
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>




















        
            

    

    
    <h4 class="name" id="reset"><span class="type-signature"></span>reset<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    Resets the service, removing access and requiring the service to be
re-authorized. Also removes any additional values stored in the service's
storage.
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>




















        
            

    

    
    <h4 class="name" id="setAdditionalClaims"><span class="type-signature"></span>setAdditionalClaims<span class="signature">(additionalClaims)</span><span class="type-signature"> &rarr; (non-null) {<a href="Service_.html">Service_</a>}</span></h4>
    

    



<div class="description">
    Sets additional JWT claims to use for Service Account authorization.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>additionalClaims</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object.&lt;string, string></span>


            
            </td>

            

            

            <td class="description last">The additional claims, as
    key-value pairs.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    This service, for chaining.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Service_.html">Service_</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setAuthorizationBaseUrl"><span class="type-signature"></span>setAuthorizationBaseUrl<span class="signature">(authorizationBaseUrl)</span><span class="type-signature"> &rarr; (non-null) {<a href="Service_.html">Service_</a>}</span></h4>
    

    



<div class="description">
    Sets the service's authorization base URL (required). For Google services
this URL should be
https://accounts.google.com/o/oauth2/auth.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>authorizationBaseUrl</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last">The authorization endpoint base URL.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    This service, for chaining.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Service_.html">Service_</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setCache"><span class="type-signature"></span>setCache<span class="signature">(cache)</span><span class="type-signature"> &rarr; (non-null) {<a href="Service_.html">Service_</a>}</span></h4>
    

    



<div class="description">
    Sets the cache to use when persisting credentials (optional). Using a cache
will reduce the need to read from the property store and may increase
performance. In most cases this should be a private cache, but a public cache
may be appropriate if you want to share access across users.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>cache</code></td>
            

            <td class="type">
            
                
<span class="param-type">CacheService.Cache</span>


            
            </td>

            

            

            <td class="description last">The cache to use when persisting
    credentials.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-see">See:</dt>
    <dd class="tag-see">
        <ul>
            <li><a href="https://developers.google.com/apps-script/reference/cache/">https://developers.google.com/apps-script/reference/cache/</a></li>
        </ul>
    </dd>
    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    This service, for chaining.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Service_.html">Service_</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setCallbackFunction"><span class="type-signature"></span>setCallbackFunction<span class="signature">(callbackFunctionName)</span><span class="type-signature"> &rarr; (non-null) {<a href="Service_.html">Service_</a>}</span></h4>
    

    



<div class="description">
    Sets the name of the authorization callback function (required). This is the
function that will be called when the user completes the authorization flow
on the service provider's website. The callback accepts a request parameter,
which should be passed to this service's <code>handleCallback()</code> method
to complete the process.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>callbackFunctionName</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last">The name of the callback function.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    This service, for chaining.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Service_.html">Service_</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setClientId"><span class="type-signature"></span>setClientId<span class="signature">(clientId)</span><span class="type-signature"> &rarr; (non-null) {<a href="Service_.html">Service_</a>}</span></h4>
    

    



<div class="description">
    Sets the client ID to use for the OAuth flow (required). You can create
client IDs in the "Credentials" section of a Google Developers Console
project. Although you can use any project with this library, it may be
convinient to use the project that was created for your script. These
projects are not visible if you visit the console directly, but you can
access it by click on the menu item "Resources > Advanced Google services" in
the Script Editor, and then click on the link "Google Developers Console" in
the resulting dialog.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>clientId</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last">The client ID to use for the OAuth flow.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    This service, for chaining.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Service_.html">Service_</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setClientSecret"><span class="type-signature"></span>setClientSecret<span class="signature">(clientSecret)</span><span class="type-signature"> &rarr; (non-null) {<a href="Service_.html">Service_</a>}</span></h4>
    

    



<div class="description">
    Sets the client secret to use for the OAuth flow (required). See the
documentation for <code>setClientId()</code> for more information on how to
create client IDs and secrets.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>clientSecret</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last">The client secret to use for the OAuth flow.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    This service, for chaining.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Service_.html">Service_</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setCodeChallengeMethod"><span class="type-signature"></span>setCodeChallengeMethod<span class="signature">(method)</span><span class="type-signature"> &rarr; (non-null) {<a href="Service_.html">Service_</a>}</span></h4>
    

    



<div class="description">
    Set the code challenge method for PKCE. The default value method
when a code verifier is set is S256.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>method</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last">Challenge method, either "S256" or "plain"</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    This service, for chaining
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Service_.html">Service_</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setCodeVerififer"><span class="type-signature"></span>setCodeVerififer<span class="signature">(codeVerifier)</span><span class="type-signature"> &rarr; (non-null) {<a href="Service_.html">Service_</a>}</span></h4>
    

    



<div class="description">
    Set the code verifier used for PKCE. For most use cases,
prefer `generateCodeVerifier` to automatically initialize the
value with a generated challenge string.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>codeVerifier</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last">A random challenge string</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    This service, for chaining
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Service_.html">Service_</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setExpirationMinutes"><span class="type-signature"></span>setExpirationMinutes<span class="signature">(expirationMinutes)</span><span class="type-signature"> &rarr; (non-null) {<a href="Service_.html">Service_</a>}</span></h4>
    

    



<div class="description">
    Sets number of minutes that a token obtained through Service Account
authorization should be valid. Default: 60 minutes.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>expirationMinutes</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last">The expiration duration in minutes.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    This service, for chaining.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Service_.html">Service_</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setGrantType"><span class="type-signature"></span>setGrantType<span class="signature">(grantType)</span><span class="type-signature"> &rarr; (non-null) {<a href="Service_.html">Service_</a>}</span></h4>
    

    



<div class="description">
    Sets the OAuth2 grant_type to use when obtaining an access token. This does
not need to be set when using either the authorization code flow (AKA
3-legged OAuth) or the service account flow. The most common usage is to set
it to "client_credentials" and then also set the token headers to include
the Authorization header required by the OAuth2 provider.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>grantType</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last">The OAuth2 grant_type value.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    This service, for chaining.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Service_.html">Service_</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setIssuer"><span class="type-signature"></span>setIssuer<span class="signature">(issuer)</span><span class="type-signature"> &rarr; (non-null) {<a href="Service_.html">Service_</a>}</span></h4>
    

    



<div class="description">
    Sets the issuer (iss) value to use for Service Account authorization.
If not set the client ID will be used instead.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>issuer</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last">This issuer value</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    This service, for chaining.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Service_.html">Service_</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setLock"><span class="type-signature"></span>setLock<span class="signature">(lock)</span><span class="type-signature"> &rarr; (non-null) {<a href="Service_.html">Service_</a>}</span></h4>
    

    



<div class="description">
    Sets the lock to use when checking and refreshing credentials (optional).
Using a lock will ensure that only one execution will be able to access the
stored credentials at a time. This can prevent race conditions that arise
when two executions attempt to refresh an expired token.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>lock</code></td>
            

            <td class="type">
            
                
<span class="param-type">LockService.Lock</span>


            
            </td>

            

            

            <td class="description last">The lock to use when accessing credentials.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-see">See:</dt>
    <dd class="tag-see">
        <ul>
            <li><a href="https://developers.google.com/apps-script/reference/lock/">https://developers.google.com/apps-script/reference/lock/</a></li>
        </ul>
    </dd>
    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    This service, for chaining.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Service_.html">Service_</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setParam"><span class="type-signature"></span>setParam<span class="signature">(name, value)</span><span class="type-signature"> &rarr; (non-null) {<a href="Service_.html">Service_</a>}</span></h4>
    

    



<div class="description">
    Sets an additional parameter to use when constructing the authorization URL
(optional). See the documentation for your service provider for information
on what parameter values they support.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>name</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last">The parameter name.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>value</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last">The parameter value.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    This service, for chaining.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Service_.html">Service_</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setPrivateKey"><span class="type-signature"></span>setPrivateKey<span class="signature">(privateKey)</span><span class="type-signature"> &rarr; (non-null) {<a href="Service_.html">Service_</a>}</span></h4>
    

    



<div class="description">
    Sets the private key to use for Service Account authorization.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>privateKey</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last">The private key.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    This service, for chaining.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Service_.html">Service_</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setPropertyStore"><span class="type-signature"></span>setPropertyStore<span class="signature">(propertyStore)</span><span class="type-signature"> &rarr; (non-null) {<a href="Service_.html">Service_</a>}</span></h4>
    

    



<div class="description">
    Sets the property store to use when persisting credentials (required). In
most cases this should be user properties, but document or script properties
may be appropriate if you want to share access across users.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>propertyStore</code></td>
            

            <td class="type">
            
                
<span class="param-type">PropertiesService.Properties</span>


            
            </td>

            

            

            <td class="description last">The property store to use
    when persisting credentials.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-see">See:</dt>
    <dd class="tag-see">
        <ul>
            <li><a href="https://developers.google.com/apps-script/reference/properties/">https://developers.google.com/apps-script/reference/properties/</a></li>
        </ul>
    </dd>
    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    This service, for chaining.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Service_.html">Service_</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setRedirectUri"><span class="type-signature"></span>setRedirectUri<span class="signature">(redirectUri)</span><span class="type-signature"> &rarr; (non-null) {<a href="Service_.html">Service_</a>}</span></h4>
    

    



<div class="description">
    Sets the URI to redirect to when the OAuth flow has completed. By default the
library will provide this value automatically, but in some rare cases you may
need to override it.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>redirectUri</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last">The redirect URI.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    This service, for chaining.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Service_.html">Service_</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setRefreshUrl"><span class="type-signature"></span>setRefreshUrl<span class="signature">(refreshUrl)</span><span class="type-signature"> &rarr; (non-null) {<a href="Service_.html">Service_</a>}</span></h4>
    

    



<div class="description">
    Sets the service's refresh URL. Some OAuth providers require a different URL
to be used when generating access tokens from a refresh token.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>refreshUrl</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last">The refresh endpoint URL.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    This service, for chaining.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Service_.html">Service_</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setScope"><span class="type-signature"></span>setScope<span class="signature">(scope, optSeparator<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; (non-null) {<a href="Service_.html">Service_</a>}</span></h4>
    

    



<div class="description">
    Sets the scope or scopes to request during the authorization flow (optional).
If the scope value is an array it will be joined using the separator before
being sent to the server, which is is a space character by default.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>scope</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>
|

<span class="param-type">Array.&lt;string></span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last">The scope or scopes to request.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>optSeparator</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last">The optional separator to use when joining
    multiple scopes. Default: space.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    This service, for chaining.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Service_.html">Service_</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setSubject"><span class="type-signature"></span>setSubject<span class="signature">(subject)</span><span class="type-signature"> &rarr; (non-null) {<a href="Service_.html">Service_</a>}</span></h4>
    

    



<div class="description">
    Sets the subject (sub) value to use for Service Account authorization.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>subject</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last">This subject value</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    This service, for chaining.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Service_.html">Service_</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setTokenFormat"><span class="type-signature"></span>setTokenFormat<span class="signature">(tokenFormat)</span><span class="type-signature"> &rarr; (non-null) {<a href="Service_.html">Service_</a>}</span></h4>
    

    



<div class="description">
    Sets the format of the returned token. Default: OAuth2.TOKEN_FORMAT.JSON.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>tokenFormat</code></td>
            

            <td class="type">
            
                
<span class="param-type">OAuth2.TOKEN_FORMAT</span>


            
            </td>

            

            

            <td class="description last">The format of the returned token.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    This service, for chaining.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Service_.html">Service_</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setTokenHeaders"><span class="type-signature"></span>setTokenHeaders<span class="signature">(tokenHeaders)</span><span class="type-signature"> &rarr; (non-null) {<a href="Service_.html">Service_</a>}</span></h4>
    

    



<div class="description">
    Sets the additional HTTP headers that should be sent when retrieving or
refreshing the access token.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>tokenHeaders</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object.&lt;string, string></span>


            
            </td>

            

            

            <td class="description last">A map of header names to values.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    This service, for chaining.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Service_.html">Service_</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setTokenMethod"><span class="type-signature"></span>setTokenMethod<span class="signature">(tokenMethod)</span><span class="type-signature"> &rarr; (non-null) {<a href="Service_.html">Service_</a>}</span></h4>
    

    



<div class="description">
    Sets the HTTP method to use when retrieving or refreshing the access token.
Default: "post".
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>tokenMethod</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last">The HTTP method to use.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    This service, for chaining.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Service_.html">Service_</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setTokenPayloadHandler"><span class="type-signature"></span>setTokenPayloadHandler<span class="signature">(tokenHandler)</span><span class="type-signature"> &rarr; (non-null) {<a href="Service_.html">Service_</a>}</span></h4>
    

    



<div class="description">
    Sets an additional function to invoke on the payload of the access token
request.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>tokenHandler</code></td>
            

            <td class="type">
            
                
<span class="param-type"><a href="global.html#tokenHandler">tokenHandler</a></span>


            
            </td>

            

            

            <td class="description last">tokenHandler A function to invoke on the
    payload of the request for an access token.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    This service, for chaining.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Service_.html">Service_</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setTokenUrl"><span class="type-signature"></span>setTokenUrl<span class="signature">(tokenUrl)</span><span class="type-signature"> &rarr; (non-null) {<a href="Service_.html">Service_</a>}</span></h4>
    

    



<div class="description">
    Sets the service's token URL (required). For Google services this URL should
be https://accounts.google.com/o/oauth2/token.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>tokenUrl</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last">The token endpoint URL.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    This service, for chaining.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Service_.html">Service_</a></span>


    </dd>
</dl>

    





        
    

    

    
</article>

</section>




</div>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Service_.html">Service_</a></li><li><a href="Storage_.html">Storage_</a></li></ul><h3>Global</h3><ul><li><a href="global.html#createService">createService</a></li><li><a href="global.html#decodeJwt_">decodeJwt_</a></li><li><a href="global.html#encodeChallenge_">encodeChallenge_</a></li><li><a href="global.html#encodeJwt_">encodeJwt_</a></li><li><a href="global.html#encodeUrlSafeBase64NoPadding_">encodeUrlSafeBase64NoPadding_</a></li><li><a href="global.html#extend_">extend_</a></li><li><a href="global.html#getRedirectUri">getRedirectUri</a></li><li><a href="global.html#getServiceNames">getServiceNames</a></li><li><a href="global.html#TOKEN_FORMAT">TOKEN_FORMAT</a></li><li><a href="global.html#toLowerCaseKeys_">toLowerCaseKeys_</a></li></ul>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a>
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>